package com.htfyun.hardware;


import android.text.TextUtils;
import com.htfyun.nvrom.NVRomIntegerInfo;
import com.htfyun.nvrom.NVRomOperation;
import com.htfyun.nvrom.NVRomStringInfo;

public class NVRomController {

    private static String TAG = "NVRomController";

    private static NVRomController sInstance;

    private NVRomOperation nvRomOperation = NVRomOperation.getInstance();


    private NVRomController() {
    }

    public static synchronized NVRomController getInstance() {
        if (sInstance == null) {
            sInstance = new NVRomController();
        }
        return sInstance;
    }

    public NVRomIntegerInfo[] getAllIntegerInfoFromNVRomData(int startOffset, int count) {
        return nvRomOperation.getAllIntegerNVRom(startOffset, count);
    }

    public int getCountOfAllIntegerInfo() {
        return nvRomOperation.getCountOfAllIntegerNVRom();
    }

    public NVRomStringInfo[] getAllStringInfoFromNVRomData(int startOffset, int count) {
        return nvRomOperation.getAllStringNVRom(startOffset, count);
    }

    public int getCountOfAllStringInfo() {
        return nvRomOperation.getCountOfAllStringNVRom();
    }

    public boolean removeIntegerFromNVRomData(String key) {
        return nvRomOperation.removeIntegerNVRom(key);
    }

    public boolean removeStringFromNVRomData(String key) {
        return nvRomOperation.removeStringNVRom(key);
    }

    public int getNVRomInt(String key, int defValue) {
        if (TextUtils.isEmpty(key)) {
            return defValue;
        }

        return nvRomOperation.getIntegerNVRom(key, defValue);
    }
    public boolean setNVRomInt(String key, int value) {
        if (TextUtils.isEmpty(key)) {
            return false;
        }

        return nvRomOperation.setIntegerNVRom(key, value);

    }


    public boolean setNVRomString(String key, String str) {
        if (TextUtils.isEmpty(key)) {
            return false;
        }

        return nvRomOperation.setStringNVRom(key, str);
    }

    public String getNVRomString(String key) {
        if (TextUtils.isEmpty(key)) {
            return "";
        }

        return nvRomOperation.getStringNVRom(key);
    }

}
